package xj.model.uml;

import static xj.model.uml.UMLModelConstants.ATTR_TEXT;
import xj.meta.AbstractModelElement;

public class Note extends AbstractModelElement {

  public Note() {
    this(null);
  }

  public Note(String text) {
    setText(text);
    destructable = false;
    //preserved = true;
  }

  public String getText() {
    return text;
  }

  public void setText(String text) {
    this.text = text;
    setAttribute(ATTR_TEXT, text);
  }

  @Override
  public String toString() {
    return "Note: text=" + text;
  }

  @Override
  protected boolean asElement(String attrName) {
    if (attrName != null) {
      return (attrName.equals(ATTR_TEXT));
    }
    return false;
  }

  @Override
  protected boolean inCDATASection(String name) {
    return asElement(name);
  }

  @Override
  public Object clone() throws CloneNotSupportedException {
    Note a = (Note) super.clone();
    a.setText(text);
    return a;
  }

  protected String text;

}
